/**
 *
 * @author ilya portnyagin iportnyagin@gmail.com
 */

package ru.portnyagin.helpdeskru.service;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import ru.portnyagin.helpdeskru.model.Priority;
import ru.portnyagin.helpdeskru.model.Priority_;

@Stateless
public class PriorityService extends AbstractService<Priority> {
    @PersistenceContext(unitName = "HelpDeskRuPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public PriorityService() {
        super(Priority.class);
    }
    
    public List<Priority> findAll() {
        CriteriaBuilder cb = getEntityManager().getCriteriaBuilder();
        CriteriaQuery cq = cb.createQuery();
        Root<Priority> h = cq.from(Priority.class);
        cq.orderBy(cb.asc(h.get(Priority_.id)));
        return getEntityManager().createQuery(cq).getResultList();
    }

   
   
}

